package com.finer.service.impl;

import com.finer.entity.finance.FinerReciveRequest;
import com.finer.dao.FinerReciveRequestDao;
import com.finer.service.FinerReciveRequestService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * 收款需求表(FinerReciveRequest)表服务实现类
 *
 * @author makejava
 * @since 2024-10-21 10:20:38
 */
@Service("finerReciveRequestService")
public class FinerReciveRequestServiceImpl implements FinerReciveRequestService {
    @Resource
    private FinerReciveRequestDao finerReciveRequestDao;

    /**
     * 通过ID查询单条数据
     *
     * @param Id 主键
     * @return 实例对象
     */
    @Override
    public FinerReciveRequest queryById(Integer Id) {
        return this.finerReciveRequestDao.queryById(Id);
    }

    /**
     * 分页查询
     *
     * @param finerReciveRequest 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<FinerReciveRequest> queryByPage(FinerReciveRequest finerReciveRequest, PageRequest pageRequest) {
        long total = this.finerReciveRequestDao.count(finerReciveRequest);
        return new PageImpl<>(this.finerReciveRequestDao.queryAllByLimit(finerReciveRequest, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param finerReciveRequest 实例对象
     * @return 实例对象
     */
    @Override
    public FinerReciveRequest insert(FinerReciveRequest finerReciveRequest) {
        this.finerReciveRequestDao.insert(finerReciveRequest);
        return finerReciveRequest;
    }

    /**
     * 修改数据
     *
     * @param finerReciveRequest 实例对象
     * @return 实例对象
     */
    @Override
    public FinerReciveRequest update(FinerReciveRequest finerReciveRequest) {
        this.finerReciveRequestDao.update(finerReciveRequest);
        return this.queryById(finerReciveRequest.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param Id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer Id) {
        return this.finerReciveRequestDao.deleteById(Id) > 0;
    }
}
